﻿/******************************************************************************
* File description: BoxOpContinueExp.qml
* Function: 继续实验弹窗
* Current Version: 1.0.0
* Author: JNN
* Date: 2025-07-01
*  -----
*  Copyright by 博坤生物 .
 *****************************************************************************/

import QtQuick 2.12
import QtQuick.Controls 2.12
import "../components"


CustomPopupBox {

    id: root
    title: "提示"

    height: 270*dp; width: 400*dp

    property int infoState: 0   // -1未显示 0等待响应 1开始启动 2启动完成 3响应超时 4执行超时

    function startWait01(){
        infoState = 0
        timer_timeout0.start()
        timer_timeout1.stop()
    }
    function startWait02(){
        infoState = 1
        timer_timeout0.stop()
        timer_timeout1.start()
    }
    function finishWait(){
        infoState = 2
        stopTimer()
    }
    function stopTimer(){
        timer_timeout0.stop()
        timer_timeout1.stop()

    }


    Timer{
        id: timer_timeout0
        interval: config.return01Timeout
        onTriggered: {
            infoState = 3
        }
    }
    Timer{
        id: timer_timeout1
        interval: config.return02Timeout_short
        onTriggered: {
            infoState = 4
        }
    }

    contentItem: Item{

        CustomAnimatedImage{      // 等待中
            id: gif_resetting_big
            source: "qrc:/picture/loading.gif"
            anchors.verticalCenterOffset: -60*dp
            anchors.centerIn: parent
            visible: infoState === 0 || infoState === 1
            playing: visible
            speed: 2
            height: 80*dp; width: 80*dp
        }Image {            // 超时
            source: "qrc:/picture/msgError.png"
            visible: infoState===3 || infoState === 4
            anchors.centerIn: parent
            anchors.verticalCenterOffset: -60*dp
            height: 56*dp; width: 56*dp
        }
        Image {
            id: name
            anchors.centerIn: parent
            anchors.verticalCenterOffset: -60*dp
            height: 56*dp
            width: 56*dp
            visible: infoState===2
            source: "qrc:/picture/msgSuccess.png"
        }

        Text{
            text: {
                if(infoState === 0)         return "正在等待设备响应"
                else if(infoState === 1)    return "正在继续实验"
                else if(infoState === 2)    return "继续实验成功"
                else if(infoState === 3)    return "设备响应超时"
                else if(infoState === 4)    return "继续实验超时"
            }
            font.pixelSize: config.fontsize
            y: 100*dp
            anchors.horizontalCenter: parent.horizontalCenter
        }
        CustomButton{
            title: "关闭"
            defaultMode2: true
            y: 150*dp
            anchors.horizontalCenter: parent.horizontalCenter
            visible: infoState >= 2
            onClicked: {
                root.close()
            }
        }
    }




}
